<template>
  <div id="name">
    <div class="wl-body">
      <van-pull-refresh
        v-model="isLoading"
        :success-text="$t('m.sxcg')"
        @refresh="onRefresh"
      >
        <div class="top"></div>
        <div class="topbox slideOut">
          <div class="bdds slideOut">
            <div class="txtsde txtc t-left">{{ $t("m.mcbfh") }}</div>
            <div class="link-item">
              <div class="slink defcf">
                <div class="flex1">TROT</div>
                <div class="flex1">{{ $t("m.zh") }}({{ bzdw }})</div>
              </div>
              <div class="slink u-dj">
                <div class="flex1">
                  {{
                    see ? (s ? s.cashAmount.toFixed(4) : "0") : "*****"
                  }}
                </div>
                <div class="flex1">
                  {{
                    see
                      ? s
                        ? (s.cashAmount * ttoc).toFixed(2)
                        : "0"
                      : "*****"
                  }}
                </div>
              </div>
            </div>
          </div>
        </div>
        <div>
          <div class="i-title t-left mtp">— {{ $t("m.jllb") }} —</div>
        </div>

        <div class="bdds slideIn">
          <van-list
            v-model="loading"
            :finished="finished"
            :finished-text="$t('m.nomore')"
            @load="onLoad"
          >
            <div class="link-item bottml" v-for="(item, k) in lslist" :key="k">
              <div class="slink defcf">
                <div class="flex1">{{ $t("m.sl") }}</div>
                <div class="flex1">{{ $t("m.bz") }}</div>
                <div class="flex1">{{ $t("m.sj") }}</div>
              </div>
              <div class="slink u-dj">
                <div class="flex1">{{ item.price }}</div>
                <div class="flex1">TROT</div>
                <div class="flex1">{{ item.createDate }}</div>
              </div>
            </div>
          </van-list>
        </div>
      </van-pull-refresh>
    </div>
  </div>
</template>

<script>
export default {
  name: "name",
  data() {
    return {
      isPublish: false,
      isLoading: false,
      acchange: 0,
      see: "",
      s: "",
      lslist: [],
      loading: false,
      finished: false,
      pageNum: 1,
    };
  },
  created() {
    this.s = JSON.parse(sessionStorage.getItem("s"));
    if (this.$store.getters.see == "0") {
      this.see = false;
    } else {
      this.see = true;
    }
  },
  computed: {
    ttoc() {
      return this.$store.getters.ttoc;
    },
    utoc() {
      return this.$store.getters.utoc;
    },
    ttou() {
      return this.$store.getters.ttou;
    },
    bzdw() {
      if (this.$store.getters.language == "zh-CN") {
        return "CNY";
      } else {
        return "USD";
      }
    },
  },
  methods: {
    onRefresh() {
      setTimeout(() => {
        this.isLoading = false;
      }, 1000);
    },
    guanbi() {
      this.$router.go(-1);
    },

    onLoad() {
      if (this.$store.getters.nameid) {
        var datas = {
          params: {
            uid: this.$store.getters.nameid,
            pageSize: 10,
            pageNum: this.pageNum,
            type: 4,
            currency: 0,
          },
        };
        this.$get({
          url: "ums-community-history/getList",
          data: datas,
          callback: (data) => {
            this.$nextTick(function () {
              var list = data.data;
              if (list) {
                this.show = true;
                if (this.pageNum > 1) {
                  this.lslist = [...this.lslist, ...list];
                } else {
                  this.lslist = list;
                }
                this.loading = false;
                if (list.length != 0) {
                  this.pageNum++;
                } else {
                  this.finished = true;
                }
              }
            });
          },
        }).catch(() => {
          this.$toast(this.$i18n.t("m.errordata"));
        });
      } else {
        this.getuid();
      }
    },
        getuid() {
      this.$get({
        url: "wms-wallet/user-game-info/" + this.$store.getters.userWallet,
        data: {},
        callback: (data) => {
          this.$nextTick(function () {
            if (data.data) {
              this.$store.commit("nameid", data.data.id);
              this.onLoad();
            }
          });
        },
      }).catch(() => {
        this.$toast(this.$i18n.t("m.errordata"));
      });
    },
  },
};
</script>

<style lang="scss" scoped>
</style>